@extends('admin/layout')

@section('content')
    <script>
        function del()
        {
            if(confirm("确定要删除吗？"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    </script>
    <div class="content-wrapper" style="overflow: auto;">
        <!-- Content Header (Page header) -->
        <section>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li class="active">客户经理列表</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-12" style="width: 100%;">
                    <div class="box">
                        <div class="box-header with-border">
                            {{--<h3 class="box-title">内容</h3>--}}
                        </div>
                        <span id="msg" style="display: none">
                            @if (count($errors) > 0)
                                @foreach ($errors->all() as $error)
                                    <div style="width: 100%;">
                                        <span style="color: red;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ $error }}</span>
                                    </div>
                                @endforeach
                            @else
                                <div style="width: 100%;">
                                    <span style="color: green;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ Session::get('msg') }}</span>
                                </div>
                            @endif
                        </span>
                        <script type="text/javascript">
                            var _msg = $('#msg div span').text();
                            console.log(_msg);
                            if(_msg != ''){
                                layer.msg(_msg);
                            }
                        </script>
                        <div class="box-body">
                            <table class="table table-striped table-hover text-center">
                                <tr>
                                    <th>编号</th>
                                    <th>创建时间</th>
                                    <th>用户名</th>
                                    <th>手机号</th>
                                    <th>邮箱</th>
                                    <th>所属合作商</th>
                                    <th>所属工号</th>
                                    <th>状态</th>
                                    @if(Session::get('roleid') == 1)
                                        <th style="width: 220px; text-align: center;">操作</th>
                                    @endif
                                </tr>
                                @foreach($list as $value)
                                    <tr>
                                        <td>{{ $value['id'] }}</td>
                                        <td>{{ $value['create_time'] }}</td>
                                        <td>{{ $value['username'] }}</td>
                                        <td>{{ $value['phone'] }}</td>
                                        <td>{{ $value['email'] }}</td>
                                        {{--<td>{{ $value['par_id'] }}</td>--}}
                                        <td>{{ App\Partner::find($value['par_id'])['name'] }}</td>
                                        <td>{{ App\Manage::find($value['son_id'])['username'] }}</td>
                                        <td>
                                            @if($value['status'] == 1)<a class="btn btn-success btn-xs">已启用<a>
                                            @else    <a class="btn btn-danger btn-xs">已禁用<a>
                                            @endif
                                        </td>
                                        @if(Session::get('roleid') == 1)
                                        <td>
                                            <a class="btn btn-success btn-xs"  href="{{ url('admin/setStatus/'.$value['id'].'/1' )}}" >启用<a>
                                            <a class="btn btn-warning btn-xs"  href="{{ url('admin/setStatus/'.$value['id'].'/0') }}" >禁用<a>
                                            <a class="btn btn-info btn-xs"  href="{{ url('admin/getMan/'.$value['id']) }}" >修改<a>
                                            <a class="btn btn-danger btn-xs" href="{{ url('admin/delDire/'.$value['id']) }}" onclick='return del()'>删除<a>
                                        </td>
                                        @endif
                                    </tr>
                                @endforeach
                            </table>
                        </div>
                        <!-- /.box -->
                    </div>

                    <!-- /.row -->
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
@stop